home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
tipi
/
hangman.tpi
< prev
next >
Wrap
Text File
|
1993-11-05
|
3KB
|
162 lines
# HANGMAN.TPI
define head
1 3 locate 1 chr$ print$
enddef
define shoulders
2 3 locate 206 chr$ print$
enddef
define hips
3 3 locate 202 chr$ print$
enddef
define leftarm
2 2 locate 201 chr$ print$
enddef
define leftleg
3 2 locate 201 chr$ print$
4 2 locate 188 chr$ print$
enddef
define rightleg
3 4 locate 187 chr$ print$
4 4 locate 200 chr$ print$
enddef
define rightarm
2 4 locate 187 chr$ print$
enddef
define gallows
0 0 locate
214 chr$ print$
2 do
196 chr$ print$
loop
191 chr$ print$ cr
4 do
186 chr$ print$ cr
loop
200 chr$ print$
4 do
205 chr$ print$
loop
enddef
defstr word$
defstr used$
deftable wordlist
"china" "computer" "radio"
"river" "elbow" "escort"
"example" "talk" "work"
"pizza" "thing" "dangerous"
"example" "kidney" "budget"
"space" "billion" "brain"
"drawing" "winter" "message"
"monster" "visual" "unusual"
"monkey" "triangle" "magazine"
"jacket" "bottle" "alligator"
endtable
define pickword
30 random wordlist
word$ store
"" used$ store
enddef
deftable drawpart
head shoulders leftarm rightarm hips leftleg rightleg
endtable
define drawman
# draws parts of the man depending
# on n
0 cursor drawpart 1 cursor
enddef
define isupper? ( -- n )
( a$ -- a$ )
# n is true if a$ is uppercase
asc 64 >
if asc 91 <
if 1 else 0 endif
else 0 endif
enddef
define display
word$ fetch len
do
len 1 + index -
dup$ 1 mid$ isupper? if print$
else drop$ "-" print$ endif
" " print$
loop
drop$
enddef
define message
1 10 locate print$
enddef
define hangman
cls
gallows
pickword
5 10 locate display
begin
"Guess a letter." message
begin
key dup if dup endif
until
" " message
dup 27 = if cls bye endif
word$ fetch dup$
dup chr$ lcase$ dup$ ucase$ replace$
dup$ word$ store
=$ if chr$ ucase$
used$ fetch swap$ +$
used$ dup$ store
len dup drawman
3 10 locate print$
7 = if
"Sorry, You Lose!"
message
begin
key
until
word$ fetch ucase$
word$ store
5 10 locate display
"LOST" word$ store
endif
else drop 5 10 locate display
endif
word$ fetch dup$ ucase$ =$
until
"LOST" word$ fetch =$ not if
"You Win!!! "
message
endif
begin
key
until
enddef
randomize
begin
hangman
"Would you like to play again?"
message
begin
key dup if dup endif
until
chr$ ucase$ 1 left$ "Y" =$ not
until
cls
bye